<?php

/**
 * tis-tis 首页文件
 * 
 * @copyright (c)2010 昆明力行软件  保留所有权利。
 * @link http://www.tis-tis.com
 * @Author: qilei    
 * @version: 1.0.0 
*/
 
require_once '../init.php';
require_once TIS_ROOT.'/internal/common.php';
require_once TIS_ROOT.'/admin/internal/smarty_config.php';
$smarty->assign('tpl_path','templates/default');
 
//读取缓存
$sta_cache = $CACHE->readCache('sta');
$sort_cache = $CACHE->readCache('sort');
$user_cache = $CACHE->readCache('user');
$log_cache_tags = $CACHE->readCache('logtags');

//登录验证
if ($action == 'login' ||$action =='' )
{
	$username = isset($_POST['user']) ? addslashes(trim($_POST['user'])) : '';
	$password = isset($_POST['pw']) ? addslashes(trim($_POST['pw'])) : '';
	$ispersis = isset($_POST['ispersis']) ? intval($_POST['ispersis']) : false;
	$img_code = ($login_code == 'y' && isset($_POST['imgcode'])) ? addslashes(trim(strtoupper($_POST['imgcode']))) : '';

	if (checkUser($username, $password, $img_code, $login_code) === true)
	{
		setAuthCookie($username, $ispersis);
		$smarty->assign(ISLOGIN,true);
		$smarty->display('index.tpl');
		
	}else{
		$smarty->display('login.tpl');
	}
}
//登出
if ($action == 'logout')
{
	setcookie(AUTH_COOKIE_NAME, ' ', time() - 31536000, '/');
	formMsg('退出成功！','../',1);
}



$request_uri = strtolower(substr(basename($_SERVER['SCRIPT_NAME']), 0, -4));
if (ROLE == 'writer' && !in_array($request_uri, array('write_log','admin_log','twitter','attachment','blogger','comment','index','save_log','trackback')))
{
	formMsg('权限不足！','./', 0);
}


?>
